<template>
    <view class="content">
        <view class="class1">
            <view class="top" v-if="data.status == 1">
                <image src="/static/icon/wait.png" class="top-icon"></image>
                <view class="top-tit">待回访</view>
            </view>
            <view class="top" v-if="data.status == 3">
                <image src="/static/icon/yx.png" class="top-icon"></image>
                <view class="top-tit">已回访</view>
            </view>
            <view class="box">
                <view class="title2">回访信息</view>
                <view class="item">
                    <view class="item-l">经纪人</view>
                    <view class="u-flex-1">{{data.broker_name}}</view>
                </view>
                <view class="item">
                    <view class="item-l">联系电话</view>
                    <view class="u-flex-1 u-flex">
                        <view class="u-flex-1">{{data.broker_phone}}</view>
                        <view class="btn-b" @click='$call(data.broker_phone)'>一键拨号</view>
                    </view>
                </view>
                <view class="item">
                    <view class="item-l">客户姓名</view>
                    <view class="item-r">{{data.name}}</view>
                </view>
                <view class="item">
                    <view class="item-l">联系电话</view>
                    <view class="item-r">{{data.phone}}</view>
                </view>
                <view class="item u-p-b-20">
                    <view class="item-l">报备楼盘</view>
                    <view class="item-r">{{data.pro_name}}</view>
                </view>
                
                <view class="border-t" v-if="info && info.user_type != 7">
                    <view class="title">跟踪内容
                        <tetx style="font-size: 24rpx;font-weight: normal;color: #999;">（50字以内）</tetx>
                    </view>
                    <textarea v-model="content" placeholder="请输入" maxlength="50" :disabled="disabled"></textarea>
                </view>
            </view>
            
            <view class="btn" v-if="data.status != 3 && info && info.user_type == 7" @click="$noMultipleClicks(doRemind)">提醒回访</view>
            <view class="btn" v-if="data.status != 3 && info && info.user_type != 7" @click="$noMultipleClicks(doSubmit)">立即提交</view>
        </view>  
    </view>
</template>

<script>
    export default {
        data() {
            return {
                noClick:true,//连点
                content: '',
                disabled: false,
                id: '',
                data: {},
                info: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getData()
            this.getInfo()
        },
        methods: {
            // 提醒回访
            doRemind() {
                this.$ajax('remind_follow_up', {
                	user_token: this.$getSync('userToken'),
                	id: this.id,//回访id
                }).then(ret => {
                	if (ret.success == 1000) {
                		this.$toast('提醒成功');
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.msg);
                	}
                });
            },
            
            // 立即提交
            doSubmit() {
                if (!this.content) {
                    this.$toast('请输入跟踪内容');
                    return
                }
                this.$ajax('submit_follow_up', {
                	user_token: this.$getSync('userToken'),
                	id: this.id,//回访id
                    msg: this.content,//回访内容	
                }).then(ret => {
                	if (ret.success == 1000) {
                		this.$toast('提交成功');
                        setTimeout(() => {
                            uni.$emit("BACK_FOLLOW")
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.msg);
                	}
                });
            },
            
            getData() {
            	this.$ajax('follow_up_detail', {
            		user_token: this.$getSync('userToken'),
            		id: this.id,//回访id
            	}).then(ret => {
            		if (ret.success == 1000) {
            			this.data = ret.detail
                        if (ret.detail && ret.detail.status == 3) {
                            this.content = ret.detail.msg
                            this.disabled = true
                        }
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
            
            // 获取个人信息
            getInfo() {
                this.$ajax('person_detail', {
                    user_token: this.$getSync('userToken'),
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.info = ret.detail
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },
        }
    };
</script>

<style lang="scss">
    
    textarea{
        width: 100%;
        height: 200rpx;
        background-color: #f5f5f5;
        padding: 20rpx;
    }
    
    page{
        background-color: #f5f5f5;
    }
    .class1 {
        width: 100vw;
    	height: 400rpx;
    	background: linear-gradient(180deg, #3a9cf6, #3fafec, #f5f5f5);
        padding: 20rpx;
    }
    .top{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 0 0 35rpx 25rpx;
    }
    .top-icon{
        width: 69rpx;
        height: 69rpx;
        margin-right: 25rpx;
    }
    .top-tit{
        font-size: 42rpx;
        color: #fff;
    }
    
    .box{
        background-color: #fff;
        border-radius: 20rpx;
        margin-bottom: 20rpx;
        padding: 35rpx 30rpx;
    }
    .wxyy{
        font-size: 30rpx;
        color: #fe6155;
        padding-bottom: 10rpx;
    }
    .wxyy-text{
        font-size: 24rpx;
        word-break: break-all;
        white-space: pre-line;
    }
    .item{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding-bottom: 10rpx;
    }
    .name{
        font-size: 30rpx;
        font-weight: bold;
    }
    .item-l{
        width: 135rpx !important;
    }
    .item-r{
        width: 535rpx !important;
        word-break: break-all;
        white-space: pre-line;
    }
    .btn-b{
        padding: 15rpx 17rpx;
        border-radius: 10rpx;
        background-color: #ffecd2;
        font-size: 24rpx;
        line-height: 1;
        color: #803906;
        margin-left: 10rpx;
    }
    .border-t{
        border-top: 2rpx solid #e6e6e6;
    }
    .title{
        font-size: 28rpx;
        font-weight: bold;
        padding: 28rpx 0 20rpx;
    }
    .title2{
        font-size: 28rpx;
        font-weight: bold;
        padding-bottom: 20rpx;
    }
    .img-box{
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .up-photo{
        width: 168rpx;
        height: 168rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
    
    .context{
        font-size: 28rpx;
        font-weight: bold;
    }
    .active{
        color: #ff6539;
    }
    .time{
        font-size: 24rpx;
        color: #595959;
        padding-top: 5rpx;
    }
    
    .btn{
        color: #fff;
        font-size: 34rpx;
        text-align: center;
        padding: 25rpx;
        margin: 40rpx 0;
        background-color: #00a1e9;
        border-radius: 50rpx;
    }
    
</style>
